package com.jinyi.wwdeng.status

class StatusRepository(val applyStatus: String? = null, val orderStatus: String? = null) {

    /**
     * 待还款
     */
    fun isRepayNow(): Boolean {
        val order = this.orderStatus ?: ""
        return when (order) {
            OrderStatus.LOANED.name -> true
            OrderStatus.OVERDUE.name -> true
            OrderStatus.BAD_DEBT.name -> true
            else -> false
        }
    }

    /**
     * 审核中
     */
    fun isReviewing(): Boolean {
        val apply = this.applyStatus ?: ""
        return when (apply) {
            ApplyStatus.CREATED.name -> true
            ApplyStatus.SYS_CHECK.name -> true
            ApplyStatus.SYS_APROVAL.name -> true
            ApplyStatus.MANU_APROVAL.name -> true
            ApplyStatus.DS_APROVAL.name -> true
            else -> false
        }
    }

    /**
     * 放款中
     */
    fun isDisbursing(): Boolean {
        val order = this.orderStatus ?: ""
        return when (order) {
            OrderStatus.CREATED.name -> true
            OrderStatus.LENDING.name -> true
            else -> false
        }
    }

    /**
     * 被拒绝
     */
    fun isRejected(): Boolean {
        val apply = this.applyStatus ?: ""
        val order = this.orderStatus ?: ""

        val applyReject = when (apply) {
            ApplyStatus.SYS_DENIED.name -> true
            ApplyStatus.MANU_DENIED.name -> true
            ApplyStatus.DS_DENIED.name -> true
            else -> false
        }
        val orderReject = when (order) {
            OrderStatus.DENIED.name -> true
            else -> false
        }

        return (applyReject or orderReject)
    }
}